﻿using UnityEditor;
using UnityEngine;

namespace SkillEditor
{
    [CreateAssetMenu(menuName = "SkillEditor/NodeInfo")]
    public class SkillEditorNodeInfo : ScriptableObject
    {
        [DisplayOnly]
        public string id => name;

        public string group;

        public SkillEditorNodeType type;

        public SkillEditorPortInfo[] ports;

        [TextArea(3, 10)]
        public string desc;
    }

    [System.Serializable]
    public class SkillEditorPortInfo
    {
        public string name;
        public SkillEditorPortType type;
        public SkillEditorValueType valueType;
    }

    public enum SkillEditorValueType
    {
        Int,
        Float,
        String,
        Bool,
        Targets,
        Damage,
        Step,
    }

    public enum SkillEditorPortType
    {
        Input,
        Output,
    }

    public enum SkillEditorNodeType
    {
        Node,
        Action,
    }

    public class DisplayOnly : System.Attribute
    {
    }

    [CustomEditor(typeof(SkillEditorNodeInfo))]
    public class SkillEditorNodeInfoInspector : Editor
    {
        public override void OnInspectorGUI()
        {
            GUILayout.Label((target as SkillEditorNodeInfo).id, EditorStyles.boldLabel);

            base.OnInspectorGUI();
        }

        //public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        //{
        //    return EditorGUI.GetPropertyHeight(property, label, true);
        //}

        //public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        //{
        //    GUI.enabled = false;
        //    EditorGUI.PropertyField(position, property, label, true);
        //    GUI.enabled = true;
        //}
    }
}